Telegram Group & Telegram Channel
57. Matrix Subtraction.

import java.util.Scanner;

class Matrix_Subtraction {

Scanner scan;
int matrix1[][], matrix2[][], sub[][];
int row, column;

void create() {

scan = new Scanner(System.in);

System.out.println("Matrix Subtraction");

// First Matrix Creation..
System.out.println("\nEnter number of rows & columns");
row = Integer.parseInt(scan.nextLine());
column = Integer.parseInt(scan.nextLine());

matrix1 = new int[row][column];
matrix2 = new int[row][column];
sub = new int[row][column];

System.out.println("Enter the data for first matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix1[i][j] = scan.nextInt();
}
}

// Second Matrix Creation..
System.out.println("Enter the data for second matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix2[i][j] = scan.nextInt();
}
}
}

void display() {

System.out.println("\nThe First Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix1[i][j]);
}
System.out.println();
}

System.out.println("\n\nThe Second Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix2[i][j]);
}
System.out.println();
}
}

void sub() {

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

sub[i][j] = matrix1[i][j] - matrix2[i][j];
}
}

System.out.println("\n\nThe Subtraction is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + sub[i][j]);
}
System.out.println();
}
}
}

class MatrixSubtractionExample {

public static void main(String args[]) {

Matrix_Subtraction obj = new Matrix_Subtraction();

obj.create();
obj.display();
obj.sub();
}
}

@java_codings



tg-me.com/java_codings/77
Create:
Last Update:

57. Matrix Subtraction.

import java.util.Scanner;

class Matrix_Subtraction {

Scanner scan;
int matrix1[][], matrix2[][], sub[][];
int row, column;

void create() {

scan = new Scanner(System.in);

System.out.println("Matrix Subtraction");

// First Matrix Creation..
System.out.println("\nEnter number of rows & columns");
row = Integer.parseInt(scan.nextLine());
column = Integer.parseInt(scan.nextLine());

matrix1 = new int[row][column];
matrix2 = new int[row][column];
sub = new int[row][column];

System.out.println("Enter the data for first matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix1[i][j] = scan.nextInt();
}
}

// Second Matrix Creation..
System.out.println("Enter the data for second matrix :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

matrix2[i][j] = scan.nextInt();
}
}
}

void display() {

System.out.println("\nThe First Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix1[i][j]);
}
System.out.println();
}

System.out.println("\n\nThe Second Matrix is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + matrix2[i][j]);
}
System.out.println();
}
}

void sub() {

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

sub[i][j] = matrix1[i][j] - matrix2[i][j];
}
}

System.out.println("\n\nThe Subtraction is :");

for(int i=0; i &lt row; i++) {

for(int j=0; j &lt column; j++) {

System.out.print("\t" + sub[i][j]);
}
System.out.println();
}
}
}

class MatrixSubtractionExample {

public static void main(String args[]) {

Matrix_Subtraction obj = new Matrix_Subtraction();

obj.create();
obj.display();
obj.sub();
}
}

@java_codings

BY Advance Java πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_codings/77

View MORE
Open in Telegram


Advance Java ‍ Telegram | DID YOU KNOW?

Date: |

NEWS: Telegram supports Facetime video calls NOW!

Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another optionβ€”secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secureβ€”like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

Advance Java ‍ from sg


Telegram Advance Java πŸ‘¨β€πŸ’»
FROM USA